package com.nagat.ftp;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.net.SocketException;

import javax.activation.FileTypeMap;

import org.apache.commons.net.ftp.FTP;
import org.apache.commons.net.ftp.FTPClient;
import org.apache.commons.net.ftp.FTPFile;

/**
 * @author yasenagat  E-mail: yasenagat@163.com
 * @version 创建时间：2012-4-11 上午10:05:06
 * 类说明
 */
public class MyFtp {

	public static void main(String[] args) {
		
		try {
			
			FTPClient ftp = new FTPClient();
			
			ftp.connect("127.0.0.1", 21);
			
			boolean isLogin = ftp.login("a", "a");
			
			System.out.println("登录："+isLogin);
			
//			ftp.setFileType(FTP.BINARY_FILE_TYPE);
//			
//			boolean isStore = ftp.storeFile("note.txt", new FileInputStream("d:/note.txt"));
//			
//			ftp.storeFile("1.png", new FileInputStream("d:/1.png"));
//			
//			System.out.println("上传："+isStore);
			
			boolean isDown = ftp.retrieveFile("note.txt", new FileOutputStream("d:/TDDOWNLOAD/note.txt"));
			isDown = ftp.retrieveFile("1.png", new FileOutputStream("d:/TDDOWNLOAD/note.png"));
			System.out.println("下载："+isDown);
		} catch (Exception e) {
			e.printStackTrace();
		}
		
		
	}
}
